
<include file="Public:js"/>
<style>
    .swiper-slide img{display:inline-block;float:left;padding: 0.2rem;}
</style>
<div class="page-group">
    <div class="page">
        <header class="bar bar-nav">
            <a onclick="window.history.go(-1);" class="icon" style="width: 40%">
                <img src="__PUBLIC__/img/iconfont_back@2x.png" class="back_img">
            </a>
        </header>
        <div class="content doublecontent" style="margin-top: 10px">
            <img src="{$d.b_logo}" style="width: 100%;height: 18rem;">
            <div class="" style="background: #FFF;height: 115px;padding: 10px;">
                <div style="float: left;width: 60%;">
                    <div class="book_price color_price font16">￥{$d.dj|number_format=###,2}</div>
                </div>
                <div style="float: right;width: 30%">
                    <!--    未收藏 -->
                <!-- 	<div ><img src="img/huodongxiangqing_collecte@2x.png"  style="width: 20px;float: right"></div> -->
                    <!--    已收藏 -->
                    <div id="book_detail_fav">
                        <if condition="$d['is_fav'] gt 0">
                            <img src="/wechat/img/huodongxiangqing_collected@2x.png" onclick="cancel_favorite()" style="width: 20px;float: right">
                        <else/>
                            <img src="/wechat/img/huodongxiangqing_collecte@2x.png" onclick="join_favorite()" style="width: 20px;float: right">
                        </if>
                    </div>
                  <!--  <img src="img/789.jpg" style="height:50px;width: 100%">-->
                </div>
                <div class="book_name" style="margin-top: 10px;margin-left: -5px;">《{$d.sm}》</div> <br />
                <div class="book_name">{$d.zyz}</div><br />
                <div class="book_name">{$d.press}</div>
            </div>
         <!--   <div class="book_detail" onclick="window.location.href='mobile/main/BDetail.action#article_detail'">
               <div class="book_detail_link" >图文详情</div>
            </div> -->
                <div class="book_detail_real">
                    <div class="book_detail_kind">
                        <input id="recLau" type="button" value="推荐语" class="active" onclick="">
                    </div>
                    <div class="book_detail_desc" >
                        <div class="book_detail_desc_datail">
                            {$d.b_rec}
                        </div>
                    </div>
                    <div class="collect_top_menu" >
                            <input type="button" class="bookDetail "  style="color:#EC623E"  value="图文详情"  onclick="bookDetail()">
                            <input type="button"  class="goosComment"  value="商品评价" onclick="goodsComment()">
                    </div>

                    <div class="goods_judge"  id="goods_judge"  style="display:none">
                      <volist name="d_apr" id="v">
                          <div class="goods_judge_datail">
                              <img src="{$v.headimgurl}" class="book_comment_face_img"><span>{$v.nickname}</span>
                              <div class="goods_comment_data">{$v.content}</div>
                          </div>
                      </volist>
                    </div>
                    <div class="picture_article_detail" id="article_detail" >
                        <!-- 图文详情 推荐语   -->
                        {$d.bdetail}
                    </div>
                </div>
            <div class="book_relative_rec">
                <div class="book_detail_link" style="border-bottom: 1px solid #DCDCDC">
                    <input type="button" value="相关推荐" style="background: none;border: none;border-left:2px solid #EC623E">
                </div>
                <!--<div class="waterfall book_rec_div rec_div">-->
                    <!--<ul class="waterfall_ul" style="margin: 0 !important;padding: 10px">-->
                        <!--<volist name="d_rec" id="v">-->
                            <!--<li>-->
                                <!--<img src="{$v.b_logo}" style="width: 100%;height: 200px;" onclick="window.location.href='{:U("Book/detail","id=".$v['book_id'])}'">-->
                                <!--<div class="rec_div_book_name">《{$v.sm}》</div>-->
                            <!--</li>-->
                        <!--</volist>-->
                    <!--</ul>-->

                <!--</div>-->
                <div class="swiper-container" style="height: 11.2rem;    border-bottom: 0.2rem solid white;">
                    <div class="swiper-wrapper" style="height: 11rem">
                        <volist name="d_rec" id="v" mod="2">
                            <eq name="mod" value="0">
                                <div class="swiper-slide">
                                    <img src="{$v.b_logo}" style="width: 50%;height: 100%" title="{$v.title}" onclick='window.location.href="{:U('Book/detail','id='.$v['book_id'])}"' />
                            <else/>
                                    <img src="{$v.b_logo}" style="width: 50%;height: 100%" title="{$v.title}" onclick='window.location.href="{:U('Book/detail','id='.$v['book_id'])}"' />
                                </div>
                            </eq>
                            <!--<div class="swiper-slide">-->
                                <!--<img src="{$v.b_logo}" style="width: 50%;height: 100%" title="{$v.title}">-->
                                <!--<img src="{$v.b_logo}" style="width: 50%;height: 100%" title="{$v.title}">-->
                            <!--</div>-->
                        </volist>
                    </div>
                </div>
                <script>
                    $(function() {
                        $(".swiper-container").swiper({

                        });
                    });
                </script>
            </div>
        </div>

        <nav class="bar bar-tab old_bar">
                <a class="tab-item external active" href="#">
                    <input value="我要借阅" type="button" class="i_want_btn" onclick="rentbook(1,{$d.book_id})">
                </a>
                <a class="tab-item external" onclick="window.location.href='{:U("Bag/index")}'">
                    <img src="__PUBLIC__/img/schoolbag@2x.png" style="width: auto;height: 35px">
                    <span class="badge cart_num_1">
                        {$d.wrent_num}
                    </span>
                </a>
                <a class="tab-item external" href="#"  onclick="rentbook(0,{$d.book_id})">
                    <img src="__PUBLIC__/img/buy@2x.png" style="width: auto;height: 35px">
                </a>
                <a class="tab-item external"  onclick="window.location.href='{:U("Cart/index")}'">
                    <img src="__PUBLIC__/img/shoppingmarket@2x.png" style="width: auto;height: 35px">
                    <span class="badge cart_num_0">
                        {$d.wbuy_num}
                    </span>
                </a>
        </nav>
    </div>
</div>
<script>
	function bookDetail(){
		$(".bookDetail").css("color","#EC623E");
		$(".goosComment").css("color","#000");
		$("#article_detail").show();
		$("#goods_judge").hide();
	}
	function goodsComment(){
		$(".bookDetail").css("color","#000");
		$(".goosComment").css("color","#EC623E");
		$("#article_detail").hide();
		$("#goods_judge").show();
		//$(".book_relative_rec").hide();
	}

    function rentbook(type,id){
        $.post("{:U('Book/is_rentorbuy')}",{id:id,type:type},function(data){
            if(type==1){
                $str='您已借阅过此书或已加入书包，是否再次加入书包？';
            }else{
                $str='您已购买过此书或已加入购物车，是否再次加入购物车？';
            }
            if(data>0){
                if(confirm($str)){
                    joincart(type,id);
                }
            }else{
                joincart(type,id);
            }
        });

    }

    function joincart(type,id){
        $.ajax({
            type: "GET",
            url: "{:U('Book/joincart')}",
            data: {id:id,type:type},
            dataType: "json",
            success: function(data){
                var str="";
                if(type==0){
                    str="加入购物车";
                }else{
                    str="加入书包";
                }
                if(data==1){
                    $.alert("成功"+str);
                    $(".cart_num_"+type).html(parseInt($(".cart_num_"+type).html())+1);
                    $(".cart_num_"+type).removeClass('animation_shake');
                    window.setTimeout(function(){
                        $(".cart_num_"+type).addClass('animation_shake');
                    },50);
                }
            }
        });
    }

    //取消收藏
    function cancel_favorite(){
        $.ajax({
            type: "GET",
            url: "{:U('Book/cancel_fav')}",
            data: {id:{$d.book_id}},
            dataType: "json",
            success: function(data){
                if(data==1){
                    $.alert("已取消");
                    $("#book_detail_fav img").attr("src","__PUBLIC__/img/huodongxiangqing_collecte@2x.png");
                    $("#book_detail_fav img").attr("onclick","join_favorite()");
                }
            }
        });
    }

    function join_favorite(){
        $.ajax({
            type: "GET",
            url: "{:U('Book/join_fav')}",
            data: {id:{$d.book_id}},
            dataType: "json",
            success: function(data){
                if(data==1){
                    $.alert("已收藏");
                    $("#book_detail_fav img").attr("src","__PUBLIC__/img/huodongxiangqing_collected@2x.png");
                    $("#book_detail_fav img").attr("onclick","cancel_favorite()");
                }
            }
        });
    }
</script>